//
//  UserNoteContenViewController.m
//  TeacherNet
//
//  Created by slz on 2017/12/22.
//  Copyright © 2017年 bnsr. All rights reserved.
//

#import "UserNoteContenViewController.h"
#import <YYTextView.h>

@interface UserNoteContenViewController ()
@property (nonatomic,strong) TTScrollView *scrollView;
@property (nonatomic,strong) UILabel *textLabel;
@end

@implementation UserNoteContenViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    self.showNavigationBar = YES;
    [self setControllerTitle:@"笔记详情"];
    UIBarButtonItem * backItem = [UIBarButtonItem itemWithImage:@"back_icon" selectImage:@"" addTarget:self andAction:@selector(backAction)];
    self.navigationItem.leftBarButtonItem = backItem;
    
    NSInteger leftRgihtMargin = 12;
    
    _scrollView = [TTScrollView new];
    [self.view addSubview:_scrollView];
    [_scrollView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.edges.mas_equalTo(self.view);
    }];
    
    NSString * contentString = _noteModel.noteContent;
    CGFloat stringHeight = [contentString heightForFont:[UIFont systemFontOfSize:kFont_Size_Cotent_Nomal] width:kScreenWidth -  2*leftRgihtMargin];

    
    _textLabel = [UILabel new];
    _textLabel.top = 20;
    _textLabel.numberOfLines = 0;
    _textLabel.textAlignment = NSTextAlignmentCenter;
    _textLabel.left = leftRgihtMargin;
    _textLabel.textColor = kDark_TextColor_Default;
    _textLabel.fontSize = kFont_Size_Cotent_Nomal;
    [_scrollView addSubview:_textLabel];
    
    _textLabel.size = CGSizeMake(kScreenWidth - 2*leftRgihtMargin, stringHeight);
    _textLabel.text = contentString;
    stringHeight = stringHeight > kScreenHeight - 64 ? stringHeight : kScreenHeight - 24;
    _scrollView.contentSize = CGSizeMake(kScreenWidth, stringHeight);
  
    // Do any additional setup after loading the view.
}

- (void)backAction{
    [self.navigationController popViewControllerAnimated:YES];
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
